package com.demo2do.fms.admin.dao.authority;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.demo2do.fms.entity.authority.Role;
import com.demo2do.fms.entity.authority.RoleTemplate;

/**
 * 
 * @author Ysy
 */
@Dao("hibernate")
public interface RoleDao {
    
    /**
     * 
     * @param templates
     * @return
     */
    @Query("FROM Role r WHERE r.template IN ( :templates ) AND disabled = false")
    public List<Role> list(@Variable("templates") List<RoleTemplate> templates);
    
    /**
     * 
     * @param template
     * @return
     */
    @Query("SELECT COUNT(*) FROM Role r WHERE r.template = :template")
    public int count(@Variable("template") RoleTemplate template);
    
    /**
     * 
     * @param roleName
     * @return
     */
    @Query("FROM Role r WHERE r.disabled = false AND r.name = :roleName")
    public Role load(@Variable("roleName")String roleName);
    
}
